package com.marketingexpert.service.noticemgnt;

import java.util.List;

import org.springframework.dao.DataAccessException;

import com.marketingexpert.dao.NoticeDao;
import com.marketingexpert.domain.Notice;
import com.marketingexpert.exception.MarketingExpertException;

public class NoticeServiceImpl implements NoticeService {

	private NoticeDao noticeDao;
	
	public int deleteNotice(int[] noticeIds) {
		try {
			return noticeDao.deleteNotice(noticeIds);
		} catch(DataAccessException e) {
			throw new MarketingExpertException(e);
		}
	}

	public int publishNotice(Notice notice) {
		try {
			return noticeDao.publishNotice(notice);
		} catch(DataAccessException e) {
			throw new MarketingExpertException(e);
		}
	}

	public Notice queryNotice(int noticeId) {
		try {
			return noticeDao.queryNotice(noticeId);
		} catch(DataAccessException e) {
			throw new MarketingExpertException(e);
		}
	}

	public List<Notice> viewNotice(int cursor, int pageSize) {
		try {
			return noticeDao.viewNotice(cursor,pageSize);
		} catch(DataAccessException e) {
			throw new MarketingExpertException(e);
		}
	}
	
	public Notice queryNewNotice(String startTime, String endTime)
			throws MarketingExpertException {
		try {
			return noticeDao.queryNewNotice(startTime,endTime);
		} catch(DataAccessException e) {
			throw new MarketingExpertException(e);
		}
	}

	public NoticeDao getNoticeDao() {
		return noticeDao;
	}

	public void setNoticeDao(NoticeDao noticeDao) {
		this.noticeDao = noticeDao;
	}
}
